#ifndef __MODBUS_RTU_SERIAL_H__
#define __MODBUS_RTU_SERIAL_H__

#include "stdint.h"
#include "Uart_DMA.h"
#include "ring_buffer.h"



typedef uint16_t (*rtu_func)(void *ctx, void *data, uint16_t count);

typedef struct{
	ring_buffer_t* buf;
	rtu_func rtu_write_func;
	rtu_func rtu_read_func;
}rtu_dev_t;


void rtu_dev_destroy(rtu_dev_t* me);

rtu_dev_t* rtu_dev_create(uint16_t buf_size);


void rtu_dev_set_recv_cb(rtu_dev_t* me, rtu_func f);

uint16_t rtu_dev_modbus_recv(rtu_dev_t* me, void *data, uint16_t count);
uint16_t rtu_dev_uart_send(rtu_dev_t* me, void *data, uint16_t count);
#endif
